package org.xq.softcup.mq.admin.util;

import java.io.Serializable;

/**
 * 封装返回
 * 
 * @author admin
 * @param <T>
 */
public class JsonResult<T> implements Serializable {
	public static final long serialVersionUID = 42L;

	public static final int SUCCESS_CODE = 200;
	public static final int FAIL_CODE = 500;

	public static final JsonResult<String> SUCCESS = new JsonResult<String>(null);
	public static final JsonResult<String> FAIL = new JsonResult<String>(FAIL_CODE, null);

	private int code;
	private String msg;
	private T data;

	public JsonResult(){}
	public JsonResult(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	public JsonResult(T data) {
		this.code = SUCCESS_CODE;
		this.data = data;
	}

	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "JsonResult [code=" + code + ", msg=" + msg + ", data=" + data + "]";
	}

}
